package com.whnk.attendance.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.whnk.attendance.service.IMonthIncomeStatisService;
import com.whnk.attendance.vo.*;
import com.whnk.attendance.vo.MonthHumenCostListVo;
import com.whnk.common.core.utils.poi.ExcelUtil;
import com.whnk.common.core.web.controller.BaseController;
import com.whnk.common.core.web.domain.AjaxResult;
import com.whnk.common.log.annotation.Log;
import com.whnk.common.log.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 每月统计（人力成本预估）Controller
 *
 * @author whnk
 * @date 2021-11-17
 */
@Api(tags = "每月统计（人力成本预估）Controller")
@RestController
@RequestMapping("/monthHumenCost")
public class MonthHumenCostController extends BaseController
{
    @Autowired
    IMonthIncomeStatisService monthIncomeStatisService;

    /**
     * 查询每月统计（人力成本预估）列表
     */
    @ApiOperation(value = "查询每月统计（人力成本预估）列表")
   // @PreAuthorize(hasPermi = "attendance:statis:list")
    @GetMapping("/list")
    public AjaxResult list(MonthHumenCostQuery monthHumenCostQuery)
    {
        return AjaxResult.success(monthIncomeStatisService.queryHumenCostForecast(monthHumenCostQuery));
    }

    /**
     * 导出每月统计（人力成本预估）列表
     */
    @ApiOperation(value = "导出每月统计（人力成本预估）列表")
   // @PreAuthorize(hasPermi = "attendance:statis:export")
    @Log(title = "查询每月统计（人力成本预估）列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MonthHumenCostQuery monthHumenCostQuery) throws IOException
    {
        MonthHumenCostJsonVo monthHumenCostJsonVo = monthIncomeStatisService.queryHumenCostForecast(monthHumenCostQuery);
        monthIncomeStatisService.exportHumenCostForecastExcel(response, monthHumenCostJsonVo);
    }

}
